# -*- coding: utf-8 -*-
from .base import BaseTool
from .base import PrintUtils,CmdTask,FileUtils,AptUtils,ChooseTask
from .base import osversion,osarch
from .base import run_tool_file

class Tool(BaseTool):
    def __init__(self):
        self.type = BaseTool.TYPE_CONFIG
        self.name = "一键安装Qt-Creator(PC端)"
        self.autor = 'hyw666'

    def install_pc_qt_creator(self):
        PrintUtils.print_info('正在下载安装包，请耐心等待~')
        CmdTask("sudo wget https://mirrors.tuna.tsinghua.edu.cn/qt/official_releases/online_installers/qt-unified-linux-x64-online.run -O /opt/qt-unified-linux-x64-online.run",os_command=True).run()
        CmdTask("sudo chmod 777 /opt/qt-unified-linux-x64-online.run", 0).run()
        CmdTask("sudo apt update", 0).run()
        CmdTask("sudo apt install libxcb-xinerama0", 0).run()
        CmdTask("sudo /opt/qt-unified-linux-x64-online.run  --mirror https://mirrors.tuna.tsinghua.edu.cn/qt",os_command=True).run()
        PrintUtils.print_info('已为您下载并运行Qt-Creator安装包,请到桌面端安装~')
        CmdTask("sudo rm /opt/qt-unified-linux-x64-online.run", 0).run()

    def run(self):
        if osarch=='amd64':
            #正式的运行
            self.install_pc_qt_creator()
        else:
            PrintUtils.print_info('不是amd64环境，如果是板卡安装,请选择对应的选项！')  
